function bubbleObj() {};

bubbleObj.prototype.begin = function(x, y) {
	this.x = x;
	this.y = y;
	this.r = 1;
	this.alpha = 0.99;
}

bubbleObj.prototype.draw = function() {

	ctx.save();

	ctx.shadowBlur = 10;
	ctx.shadowColor = "#ffffff";
	ctx.strokeStyle = "rgba(229,221,199," + this.alpha + ")";
	ctx.lineWidth = 1.5;

	ctx.beginPath();
	ctx.arc(this.x, this.y, this.r, 0, Math.PI * 2, true);
	ctx.stroke();

	ctx.restore();

	this.y -= 0.6;
	this.r += 0.1;
	this.alpha -= 0.02;

}

function bubbleUp() { //按时间
	if (fishes.boids[0].bub == 200) {
		fishes.boids[0].bub = 0;
		for(var i = 0; i < 2; i++){
			bubble[curBubble].begin(fishes.boids[i].x, fishes.boids[i].y);
			curBubble++;
		if (curBubble == maxBubble) curBubble = 0;
		}
		
	}
}
//clickBubble
function cbObj() {}

cbObj.prototype.begin = function(x, y) {
	this.cnt = 0;
	this.x = x;
	this.y = y;
}

cbObj.prototype.count = function(n) {
	//n bubble的个数
	var freq = 10; //每个泡泡间隔多久
	for (var i = 0; i < n; i++) {
		if (this.cnt == freq * i) {
			for (var j = 0; j < 2; j++) {
				bubble[curBubble].begin(fishes.boids[j].x, fishes.boids[j].y);
				curBubble++;
				if (curBubble == maxBubble) curBubble = 0;
			}

		}
	}
	this.cnt++;
}

function drawCB() {
	for (var i = 0; i < maxCB; i++) {
		if (CB[i].cnt >= 0) {
			CB[i].count(3);
		}
	}
}